package evaluation;

/**
 * 递归求数组中的最大值 master公式求时间复杂度
 */
public class GetMax {

    public static int process(int[] arrs,int L, int R){
        if (L==R){
            return arrs[L];
        }
        //判断数组中点，》右移一位即是除以2
        int mid = L + ((R-L) >> 1);
        int leftMax = process(arrs,L,mid);
        int rightMax = process(arrs,mid+1,R);
        //娶最大值
        return Math.max(leftMax,rightMax);
    }

    public static void main(String[] args) {

        int[] arrs = {1,2,3,4,9,7,5,88,44};
        System.out.println(process(arrs,0,arrs.length-1));
    }
}
